﻿Public Class DRUGATCCODE
    Dim connect As CONDB = CONDB.NewConnection()

    Dim PROVIDER_Check As New PROVIDERSCLASS

    'Private Sub ButtonItem1_Click(sender As Object, e As EventArgs) Handles ButtonItem1.Click
    '    Dim gotoSubMenu As New drugMaster
    '    gotoSubMenu.MdiParent = Me.MdiParent
    '    Me.Close()

    '    gotoSubMenu.Dock = DockStyle.Fill
    '    gotoSubMenu.Show()
    'End Sub

    'Private Sub ButtonItem2_Click(sender As Object, e As EventArgs) Handles ButtonItem2.Click
    '    Dim gotoSubMenu As New drugATC
    '    gotoSubMenu.MdiParent = Me.MdiParent
    '    Me.Close()

    '    gotoSubMenu.Dock = DockStyle.Fill
    '    gotoSubMenu.Show()
    'End Sub

    'Private Sub ButtonItem3_Click(sender As Object, e As EventArgs) Handles ButtonItem3.Click
    '    Dim gotoSubMenu As New DRUGITEMLIST
    '    gotoSubMenu.MdiParent = Me.MdiParent
    '    Me.Close()

    '    gotoSubMenu.Dock = DockStyle.Fill
    '    gotoSubMenu.Show()
    'End Sub

    Private Sub drugATC_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim objSelectDataMasdrgatcl As New masdrgatcl
        selectDataGridAtc1()
        selectDataGridAtc2()
        selectDataGridAtc3()
        selectDataGridAtc4()
        selectDataGridAtc5()

        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc2Cmb)
        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc3Cmb)
        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc3Cmb.SelectedValue.ToString, masatc2Inatc3Cmb)



        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc4Cmb)
        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc4Cmb.SelectedValue.ToString, masatc2Inatc4Cmb)
        objSelectDataMasdrgatcl.atc3combobox(masatc2Inatc4Cmb.SelectedValue.ToString, masatc3Inatc4Cmb)



        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc5Cmb)
        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc5Cmb.SelectedValue.ToString, masatc2Inatc5Cmb)

        DesignForm(Me)
        DesignGrid(MASDRGATCL1Grid)
        DesignGrid(MASDRGATCL2Grid)
        DesignGrid(MASDRGATCL3Grid)
        DesignGrid(MASDRGATCL4Grid)
        DesignGrid(MASDRGATCL5Grid)

        PROVIDER_Check.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))

    End Sub
    Private Sub selectDataGridAtc1()
        Dim selectDataGridAtc1 As New masdrgatcl
        Dim MASDRGATCL1 As DataTable
        MASDRGATCL1 = connect.GetTable(selectDataGridAtc1.selectMasdrgatcl1_)
        MASDRGATCL1Grid.PrimaryGrid.DataSource = MASDRGATCL1
    End Sub
    Private Sub selectDataGridAtc2()
        Dim selectDataGridAtc2 As New masdrgatcl
        Dim MASDRGATCL2 As DataTable
        MASDRGATCL2 = connect.GetTable(selectDataGridAtc2.selectMasdrgatcl2_)
        MASDRGATCL2Grid.PrimaryGrid.DataSource = MASDRGATCL2
    End Sub
    Private Sub selectDataGridAtc3()
        Dim selectDataGridAtc3 As New masdrgatcl
        Dim MASDRGATCL3 As DataTable
        MASDRGATCL3 = connect.GetTable(selectDataGridAtc3.selectMasdrgatcl3_)
        MASDRGATCL3Grid.PrimaryGrid.DataSource = MASDRGATCL3
    End Sub
    Private Sub selectDataGridAtc4()
        Dim selectDataGridAtc4 As New masdrgatcl
        Dim MASDRGATCL4 As DataTable
        MASDRGATCL4 = connect.GetTable(selectDataGridAtc4.selectMasdrgatcl4_)
        MASDRGATCL4Grid.PrimaryGrid.DataSource = MASDRGATCL4
    End Sub
    Private Sub selectDataGridAtc5()
        Dim selectDataGridAtc5 As New masdrgatcl
        Dim MASDRGATCL5 As DataTable
        MASDRGATCL5 = connect.GetTable(selectDataGridAtc5.selectMasdrgatcl5_)
        MASDRGATCL5Grid.PrimaryGrid.DataSource = MASDRGATCL5
    End Sub

    Private Sub masatc1Inatc3Cmb_SelectedValueChanged(sender As Object, e As EventArgs) Handles masatc1Inatc3Cmb.SelectedValueChanged
        masatc2Inatc3Cmb.SelectedValue = ""
        Dim objChangeCmb As New masdrgatcl
        If masatc1Inatc3Cmb.SelectedValue IsNot Nothing Then
            objChangeCmb.atc2combobox(masatc1Inatc3Cmb.SelectedValue.ToString, masatc2Inatc3Cmb)
        End If
    End Sub

    Private Sub masatc1Inatc4Cmb_SelectedValueChanged(sender As Object, e As EventArgs) Handles masatc1Inatc4Cmb.SelectedValueChanged
        masatc2Inatc4Cmb.SelectedValue = ""
        Dim objChangeCmb As New masdrgatcl
        If masatc1Inatc4Cmb.SelectedValue IsNot Nothing Then
            objChangeCmb.atc2combobox(masatc1Inatc4Cmb.SelectedValue.ToString, masatc2Inatc4Cmb)
        End If
    End Sub

    Private Sub masatc2Inatc4Cmb_SelectedValueChanged(sender As Object, e As EventArgs) Handles masatc2Inatc4Cmb.SelectedValueChanged
        masatc3Inatc4Cmb.SelectedValue = ""
        Dim objChangeCmb As New masdrgatcl
        If masatc2Inatc4Cmb.SelectedValue IsNot Nothing Then
            objChangeCmb.atc3combobox(masatc2Inatc4Cmb.SelectedValue.ToString, masatc3Inatc4Cmb)
        End If
    End Sub

    Private Sub masatc1Inatc5Cmb_SelectedValueChanged(sender As Object, e As EventArgs) Handles masatc1Inatc5Cmb.SelectedValueChanged
        masatc2Inatc5Cmb.SelectedValue = ""
        Dim objChangeCmb As New masdrgatcl
        If masatc1Inatc5Cmb.SelectedValue IsNot Nothing Then
            objChangeCmb.atc2combobox(masatc1Inatc5Cmb.SelectedValue.ToString, masatc2Inatc5Cmb)
        End If
    End Sub

    Private Sub masatc2Inatc5Cmb_SelectedValueChanged(sender As Object, e As EventArgs) Handles masatc2Inatc5Cmb.SelectedValueChanged
        masatc3Inatc5Cmb.SelectedValue = ""
        Dim objChangeCmb As New masdrgatcl
        If masatc2Inatc5Cmb.SelectedValue IsNot Nothing Then
            objChangeCmb.atc3combobox(masatc2Inatc5Cmb.SelectedValue.ToString, masatc3Inatc5Cmb)
        End If
    End Sub

    Private Sub masatc3Inatc5Cmb_SelectedValueChanged(sender As Object, e As EventArgs) Handles masatc3Inatc5Cmb.SelectedValueChanged
        masatc4Inatc5Cmb.SelectedValue = ""
        Dim objChangeCmb As New masdrgatcl
        If masatc3Inatc5Cmb.SelectedValue IsNot Nothing Then
            objChangeCmb.atc4combobox(masatc3Inatc5Cmb.SelectedValue.ToString, masatc4Inatc5Cmb)
        End If
    End Sub



    Private Sub addMasdrgatcl1_Click(sender As Object, e As EventArgs) Handles addMasdrgatcl1.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If ATCL1CODETxt.Text.ToString.Length > 0 And AL1NAMETxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New masdrgatcl
                    objInsertData.ATCL1CODE_ = ATCL1CODETxt.Text
                    objInsertData.AL1NAME_ = AL1NAMETxt.Text
                    objInsertData.STATUS_ = masdrgatcl1StatusChk.Checked
                    objInsertData.insertMasdrgatcl1Data()


                    selectDataGridAtc1()


                    Dim objSelectDataMasdrgatcl As New masdrgatcl

                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc2Cmb)
                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc3Cmb)
                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc4Cmb)
                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc5Cmb)

                    ATCL1CODETxt.Text = ""
                    AL1NAMETxt.Text = ""
                    masdrgatcl1StatusChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMasdrgatcl1_Click(sender As Object, e As EventArgs) Handles editMasdrgatcl1.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If ATCL1CODETxt.Text.ToString.Length > 0 And AL1NAMETxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการออกฤทธิ์ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New masdrgatcl
                        objEditData.ATCL1CODE_ = ATCL1CODETxt.Text
                        objEditData.AL1NAME_ = AL1NAMETxt.Text
                        objEditData.STATUS_ = masdrgatcl1StatusChk.Checked
                        objEditData.editMasdrgatcl1Data()

                        selectDataGridAtc1()

                        Dim objSelectDataMasdrgatcl As New masdrgatcl
                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc2Cmb)
                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc3Cmb)
                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc4Cmb)
                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc5Cmb)

                        ATCL1CODETxt.Text = ""
                        AL1NAMETxt.Text = ""
                        masdrgatcl1StatusChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
                addMasdrgatcl1.Enabled = True
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub addMasdrgatcl2_Click(sender As Object, e As EventArgs) Handles addMasdrgatcl2.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If ATCL2CODETxt.Text.ToString.Length > 0 And AL2NAMETxt.Text.ToString.Length > 0 And masatc1Inatc2Cmb.SelectedValue.ToString.Length > 0 Then
                    Dim objInsertData As New masdrgatcl
                    objInsertData.atcl1InAtcl2_ = masatc1Inatc2Cmb.SelectedValue
                    objInsertData.ATCL2CODE_ = ATCL2CODETxt.Text
                    objInsertData.AL2NAME_ = AL2NAMETxt.Text
                    objInsertData.STATUS_ = masdrgatcl2STATUSChk.Checked
                    objInsertData.insertMasdrgatcl2Data()

                    selectDataGridAtc2()

                    Dim objSelectDataMasdrgatcl As New masdrgatcl

                    objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc3Cmb.SelectedValue.ToString, masatc2Inatc3Cmb)
                    objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc4Cmb.SelectedValue.ToString, masatc2Inatc4Cmb)
                    objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc5Cmb.SelectedValue.ToString, masatc2Inatc5Cmb)

                    ATCL2CODETxt.Text = ""
                    AL2NAMETxt.Text = ""
                    masdrgatcl2STATUSChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMasdrgatcl2_Click(sender As Object, e As EventArgs) Handles editMasdrgatcl2.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If ATCL2CODETxt.Text.ToString.Length > 0 And AL2NAMETxt.Text.ToString.Length > 0 And masatc1Inatc2Cmb.SelectedValue.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการออกฤทธิ์ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New masdrgatcl
                        objEditData.atcl1InAtcl2_ = masatc1Inatc2Cmb.SelectedValue
                        objEditData.ATCL2CODE_ = ATCL2CODETxt.Text
                        objEditData.AL2NAME_ = AL2NAMETxt.Text
                        objEditData.STATUS_ = masdrgatcl2STATUSChk.Checked
                        objEditData.editMasdrgatcl2Data()

                        selectDataGridAtc2()

                        Dim objSelectDataMasdrgatcl As New masdrgatcl

                        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc3Cmb.SelectedValue.ToString, masatc2Inatc3Cmb)
                        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc4Cmb.SelectedValue.ToString, masatc2Inatc4Cmb)
                        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc5Cmb.SelectedValue.ToString, masatc2Inatc5Cmb)

                        ATCL2CODETxt.Text = ""
                        AL2NAMETxt.Text = ""
                        masdrgatcl2STATUSChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
                addMasdrgatcl1.Enabled = True
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub addMasdrgatcl3_Click(sender As Object, e As EventArgs) Handles addMasdrgatcl3.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If masatc1Inatc3Cmb.SelectedValue.ToString.Length > 0 And masatc2Inatc3Cmb.SelectedValue.ToString.Length > 0 And ATCL3CODETxt.Text.ToString.Length > 0 And AL3NAMETxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New masdrgatcl
                    objInsertData.atcl2InAtcl3_ = masatc2Inatc3Cmb.SelectedValue
                    objInsertData.ATCL3CODE_ = ATCL3CODETxt.Text
                    objInsertData.AL3NAME_ = AL3NAMETxt.Text
                    objInsertData.STATUS_ = masdrgatcl3STATUSChk.Checked
                    objInsertData.insertMasdrgatcl3Data()

                    selectDataGridAtc3()

                    Dim objSelectDataMasdrgatcl As New masdrgatcl

                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc3Cmb)
                    objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc3Cmb.SelectedValue.ToString, masatc2Inatc3Cmb)

                    objSelectDataMasdrgatcl.atc3combobox(masatc2Inatc4Cmb.SelectedValue.ToString, masatc3Inatc4Cmb)
                    objSelectDataMasdrgatcl.atc3combobox(masatc2Inatc5Cmb.SelectedValue, masatc3Inatc5Cmb)

                    ATCL3CODETxt.Text = ""
                    AL3NAMETxt.Text = ""
                    masdrgatcl3STATUSChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMasdrgatcl3_Click(sender As Object, e As EventArgs) Handles editMasdrgatcl3.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If masatc1Inatc3Cmb.SelectedValue.ToString.Length > 0 And masatc2Inatc3Cmb.SelectedValue.ToString.Length > 0 And ATCL3CODETxt.Text.ToString.Length > 0 And AL3NAMETxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการออกฤทธิ์ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New masdrgatcl
                        objEditData.atcl2InAtcl3_ = masatc2Inatc3Cmb.SelectedValue
                        objEditData.ATCL3CODE_ = ATCL3CODETxt.Text
                        objEditData.AL3NAME_ = AL3NAMETxt.Text
                        objEditData.STATUS_ = masdrgatcl3STATUSChk.Checked
                        objEditData.editMasdrgatcl3Data()

                        selectDataGridAtc3()

                        Dim objSelectDataMasdrgatcl As New masdrgatcl
                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc3Cmb)
                        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc3Cmb.SelectedValue.ToString, masatc2Inatc3Cmb)

                        objSelectDataMasdrgatcl.atc3combobox(masatc2Inatc4Cmb.SelectedValue.ToString, masatc3Inatc4Cmb)
                        objSelectDataMasdrgatcl.atc3combobox(masatc2Inatc5Cmb.SelectedValue.ToString, masatc3Inatc5Cmb)

                        ATCL3CODETxt.Text = ""
                        AL3NAMETxt.Text = ""
                        masdrgatcl3STATUSChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
                addMasdrgatcl3.Enabled = True
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub addMasdrgatcl4_Click(sender As Object, e As EventArgs) Handles addMasdrgatcl4.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If masatc1Inatc4Cmb.SelectedValue.ToString.Length > 0 And masatc2Inatc4Cmb.SelectedValue.ToString.Length > 0 And masatc3Inatc4Cmb.SelectedValue.ToString.Length > 0 And ATCL4CODETxt.Text.ToString.Length > 0 And AL4NAMETxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New masdrgatcl
                    objInsertData.atcl3InAtcl4_ = masatc3Inatc4Cmb.SelectedValue
                    objInsertData.ATCL4CODE_ = ATCL4CODETxt.Text
                    objInsertData.AL4NAME_ = AL4NAMETxt.Text
                    objInsertData.STATUS_ = masdrgatcl4STATUSChk.Checked
                    objInsertData.insertMasdrgatcl4Data()

                    selectDataGridAtc4()

                    Dim objSelectDataMasdrgatcl As New masdrgatcl
                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc4Cmb)
                    objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc4Cmb.SelectedValue.ToString, masatc2Inatc4Cmb)


                    ATCL4CODETxt.Text = ""
                    AL4NAMETxt.Text = ""
                    masdrgatcl4STATUSChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMasdrgatcl4_Click(sender As Object, e As EventArgs) Handles editMasdrgatcl4.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If masatc1Inatc4Cmb.SelectedValue.ToString.Length > 0 And masatc2Inatc4Cmb.SelectedValue.ToString.Length > 0 And masatc3Inatc4Cmb.SelectedValue.ToString.Length > 0 And ATCL4CODETxt.Text.ToString.Length > 0 And AL4NAMETxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการออกฤทธิ์ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New masdrgatcl
                        objEditData.atcl3InAtcl4_ = masatc3Inatc4Cmb.SelectedValue
                        objEditData.ATCL4CODE_ = ATCL4CODETxt.Text
                        objEditData.AL4NAME_ = AL4NAMETxt.Text
                        objEditData.STATUS_ = masdrgatcl4STATUSChk.Checked
                        objEditData.editMasdrgatcl4Data()

                        selectDataGridAtc4()


                        Dim objSelectDataMasdrgatcl As New masdrgatcl

                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc4Cmb)
                        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc4Cmb.SelectedValue.ToString, masatc2Inatc4Cmb)


                        ATCL4CODETxt.Text = ""
                        AL4NAMETxt.Text = ""
                        masdrgatcl4STATUSChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
                addMasdrgatcl4.Enabled = True
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub addMasdrgatcl5_Click(sender As Object, e As EventArgs) Handles addMasdrgatcl5.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If masatc1Inatc5Cmb.SelectedValue.ToString.Length > 0 And masatc2Inatc5Cmb.SelectedValue.ToString.Length > 0 And masatc3Inatc5Cmb.SelectedValue.ToString.Length > 0 And masatc4Inatc5Cmb.SelectedValue.ToString.Length > 0 And ATCL5CODETxt.Text.ToString.Length > 0 And AL5NAMETxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New masdrgatcl
                    objInsertData.atcl4InAtcl5_ = masatc4Inatc5Cmb.SelectedValue
                    objInsertData.ATCL5CODE_ = ATCL5CODETxt.Text
                    objInsertData.AL5NAME_ = AL5NAMETxt.Text
                    objInsertData.STATUS_ = masdrgatcl5STATUSChk.Checked
                    objInsertData.insertMasdrgatcl5Data()



                    Dim objSelectDataMasdrgatcl As New masdrgatcl
                    objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc5Cmb)
                    objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc5Cmb.SelectedValue.ToString, masatc2Inatc5Cmb)


                    ATCL5CODETxt.Text = ""
                    AL5NAMETxt.Text = ""
                    masdrgatcl5STATUSChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMasdrgatcl5_Click(sender As Object, e As EventArgs) Handles editMasdrgatcl5.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If masatc1Inatc5Cmb.SelectedValue.ToString.Length > 0 And masatc2Inatc5Cmb.SelectedValue.ToString.Length > 0 And masatc3Inatc5Cmb.SelectedValue.ToString.Length > 0 And masatc4Inatc5Cmb.SelectedValue.ToString.Length > 0 And ATCL5CODETxt.Text.ToString.Length > 0 And AL5NAMETxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการออกฤทธิ์ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New masdrgatcl
                        objEditData.atcl4InAtcl5_ = masatc4Inatc5Cmb.SelectedValue
                        objEditData.ATCL5CODE_ = ATCL5CODETxt.Text
                        objEditData.AL5NAME_ = AL5NAMETxt.Text
                        objEditData.STATUS_ = masdrgatcl5STATUSChk.Checked
                        objEditData.editMasdrgatcl5Data()

                        Dim objSelectDataMasdrgatcl As New masdrgatcl
                        objSelectDataMasdrgatcl.atc1combobox(masatc1Inatc5Cmb)
                        objSelectDataMasdrgatcl.atc2combobox(masatc1Inatc5Cmb.SelectedValue.ToString, masatc2Inatc5Cmb)


                        ATCL5CODETxt.Text = ""
                        AL5NAMETxt.Text = ""
                        masdrgatcl5STATUSChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub MASDRGATCL1Grid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASDRGATCL1Grid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 1)").Value() IsNot DBNull.Value Then
            ATCL1CODETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 1)").Value()
        Else
            ATCL1CODETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value() IsNot DBNull.Value Then
            AL1NAMETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value()
        Else
            AL1NAMETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            masdrgatcl1StatusChk.Checked = True
        Else
            masdrgatcl1StatusChk.Checked = False
        End If
        connect = CONDB.NewConnection()
        If e.GridCell.GridColumn.Name = "สถานะการเปิดใช้งาน" Then
            Try
                Dim Sql As String
                connect.BeginTrans()
                Sql = "UPDATE masdrgatcl1 SET "
                If Convert.ToBoolean(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value()) = True Then
                    Sql += "`status` = 1 "
                Else
                    Sql += "`status` = 0 "
                End If
                Sql += "WHERE `atcl1code` = '" & ATCL1CODETxt.Text & "' ;"
                connect.ExecuteNonQuery(Sql)
                connect.CommitTrans()
            Catch ex As Exception
                connect.RollbackTrans()
                MsgBox(ex.ToString)
            End Try
        End If
        connect.Dispose()
        addMasdrgatcl1.Enabled = False
    End Sub

    Private Sub MASDRGATCL2Grid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASDRGATCL2Grid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 2)").Value() IsNot DBNull.Value Then
            ATCL2CODETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 2)").Value()
        Else
            ATCL2CODETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value() IsNot DBNull.Value Then
            AL2NAMETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value()
        Else
            AL2NAMETxt.Text = ""
        End If
        'If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 1)").Value() IsNot DBNull.Value Then
        '    masatc1Inatc2Cmb.SelectedValue = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 1)").Value()
        'Else
        '    masatc1Inatc2Cmb.SelectedValue = -1
        'End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            masdrgatcl2STATUSChk.Checked = True
        Else
            masdrgatcl2STATUSChk.Checked = False
        End If
        connect = CONDB.NewConnection()
        If e.GridCell.GridColumn.Name = "สถานะการเปิดใช้งาน" Then
            Try
                Dim Sql As String
                connect.BeginTrans()
                Sql = "UPDATE masdrgatcl2 SET "
                If Convert.ToBoolean(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value()) = True Then
                    Sql += "`status` = 1 "
                Else
                    Sql += "`status` = 0 "
                End If
                Sql += "WHERE `atcl2code` = '" & ATCL2CODETxt.Text & "' ;"
                connect.ExecuteNonQuery(Sql)
                connect.CommitTrans()
            Catch ex As Exception
                connect.RollbackTrans()
                MsgBox(ex.ToString)
            End Try
        End If
        connect.Dispose()
        addMasdrgatcl2.Enabled = False
    End Sub

    Private Sub btnMasdrgatcl1_Click(sender As Object, e As EventArgs) Handles btnMasdrgatcl1.Click
        Dim nextform As New IMPORTEXCEL(Masdrgatcl1.Text)
        nextform.ShowDialog()
    End Sub

    Private Sub btnMasdrgatcl2_Click(sender As Object, e As EventArgs) Handles btnMasdrgatcl2.Click
        Dim nextform As New IMPORTEXCEL(Masdrgatcl2.Text)
        nextform.ShowDialog()
    End Sub

    Private Sub btnMasdrgatcl3_Click(sender As Object, e As EventArgs) Handles btnMasdrgatcl3.Click
        Dim nextform As New IMPORTEXCEL(Masdrgatcl3.Text)
        nextform.ShowDialog()
    End Sub

    Private Sub MASDRGATCL3Grid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASDRGATCL3Grid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 3)").Value() IsNot DBNull.Value Then
            ATCL3CODETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 3)").Value()
        Else
            ATCL3CODETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value() IsNot DBNull.Value Then
            AL3NAMETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value()
        Else
            AL3NAMETxt.Text = ""
        End If
        'If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 1)").Value() IsNot DBNull.Value Then
        '    masatc1Inatc2Cmb.SelectedValue = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 1)").Value()
        'Else
        '    masatc1Inatc2Cmb.SelectedValue = -1
        'End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            masdrgatcl3STATUSChk.Checked = True
        Else
            masdrgatcl3STATUSChk.Checked = False
        End If
        connect = CONDB.NewConnection()
        If e.GridCell.GridColumn.Name = "สถานะการเปิดใช้งาน" Then
            Try
                Dim Sql As String
                connect.BeginTrans()
                Sql = "UPDATE masdrgatcl3 SET "
                If Convert.ToBoolean(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value()) = True Then
                    Sql += "`status` = 1 "
                Else
                    Sql += "`status` = 0 "
                End If
                Sql += "WHERE `atcl3code` = '" & ATCL3CODETxt.Text & "' ;"
                connect.ExecuteNonQuery(Sql)
                connect.CommitTrans()
            Catch ex As Exception
                connect.RollbackTrans()
                MsgBox(ex.ToString)
            End Try
        End If
        connect.Dispose()
        addMasdrgatcl3.Enabled = False
    End Sub

    Private Sub MASDRGATCL4Grid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASDRGATCL4Grid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 4)").Value() IsNot DBNull.Value Then
            ATCL4CODETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 4)").Value()
        Else
            ATCL4CODETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value() IsNot DBNull.Value Then
            AL4NAMETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value()
        Else
            AL4NAMETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            masdrgatcl4STATUSChk.Checked = True
        Else
            masdrgatcl4STATUSChk.Checked = False
        End If
        connect = CONDB.NewConnection()
        If e.GridCell.GridColumn.Name = "สถานะการเปิดใช้งาน" Then
            Try
                Dim Sql As String
                connect.BeginTrans()
                Sql = "UPDATE masdrgatcl4 SET "
                If Convert.ToBoolean(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value()) = True Then
                    Sql += "`status` = 1 "
                Else
                    Sql += "`status` = 0 "
                End If
                Sql += "WHERE `atcl4code` = '" & ATCL4CODETxt.Text & "' ;"
                connect.ExecuteNonQuery(Sql)
                connect.CommitTrans()
            Catch ex As Exception
                connect.RollbackTrans()
                MsgBox(ex.ToString)
            End Try
        End If
        connect.Dispose()
        addMasdrgatcl4.Enabled = False
    End Sub

    Private Sub MASDRGATCL5Grid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles MASDRGATCL5Grid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 5)").Value() IsNot DBNull.Value Then
            ATCL5CODETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัส (ระดับที่ 5)").Value()
        Else
            ATCL5CODETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value() IsNot DBNull.Value Then
            AL5NAMETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ประเภทการออกฤทธิ์").Value()
        Else
            AL5NAMETxt.Text = ""
        End If
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            masdrgatcl5STATUSChk.Checked = True
        Else
            masdrgatcl5STATUSChk.Checked = False
        End If
        connect = CONDB.NewConnection()
        If e.GridCell.GridColumn.Name = "สถานะการเปิดใช้งาน" Then
            Try
                Dim Sql As String
                connect.BeginTrans()
                Sql = "UPDATE masdrgatcl5 SET "
                If Convert.ToBoolean(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value()) = True Then
                    Sql += "`status` = 1 "
                Else
                    Sql += "`status` = 0 "
                End If
                Sql += "WHERE `atcl5code` = '" & ATCL5CODETxt.Text & "' ;"
                connect.ExecuteNonQuery(Sql)
                connect.CommitTrans()
            Catch ex As Exception
                connect.RollbackTrans()
                MsgBox(ex.ToString)
            End Try
        End If
        connect.Dispose()
        addMasdrgatcl4.Enabled = False
    End Sub
End Class